//
//  RealNameAlertView.m
//  ZJControlsClass
//
//  Created by apple on 2024/10/27.
//

#import "RealNameAlertView.h"

@interface RealNameAlertView ()

@property (nonatomic,strong) UIView * follewView;
@property (nonatomic,strong) UILabel * alertLabel;
@property (nonatomic,strong) UILabel * msgLabel;
@property (nonatomic,strong) UIImageView * canleImg;
@property (nonatomic,strong) UIButton * enterRealNameBtn;


@end


@implementation RealNameAlertView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
        [self setUpUI];
        
        
    }
    return self;
}

-(void)setUpUI{
    
    [self addSubview:self.follewView];
    [self.follewView addSubview:self.alertLabel];
    [self.follewView addSubview:self.msgLabel];
    [self.follewView addSubview:self.canleImg];
    [self.follewView addSubview:self.enterRealNameBtn];
    
    [self.follewView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(self);
    }];
    
    
    [self.alertLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self).with.offset(ALIGN_HEIGHT_PT(25));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(25)));
    }];
    
    [self.msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(ALIGN_WIDTH_PT(10));
        make.right.equalTo(self).with.offset(-ALIGN_WIDTH_PT(10));
        make.top.equalTo(self.alertLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(28));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];
    
    [self.canleImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(-ALIGN_WIDTH_PT(15));
        make.top.equalTo(self).with.offset(ALIGN_WIDTH_PT(15));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(22), ALIGN_WIDTH_PT(22))));
    }];
    
    [self.enterRealNameBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.bottom.equalTo(self.mas_bottom).with.offset(-ALIGN_HEIGHT_PT(20));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(125), ALIGN_HEIGHT_PT(40))));
    }];
    
}

#pragma  mark -- 点击事件
-(void)respondsTo_canleAlertView{
    
    __weak typeof (self) weakSelf = self;
    if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(canleRealNameAlertView)]) {
        [weakSelf.delegate canleRealNameAlertView];
    }
}

-(void)respondsTo_enterRealNameBtn:(UIButton *)sender{
    
    __weak typeof (self)weakSelf = self;
    if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(enterRealNameViewController)]) {
        [weakSelf.delegate enterRealNameViewController];
    }
    
}



#pragma mark -- 懒加载
-(UIView *)follewView{
    if (!_follewView) {
        _follewView = [UIView new];
        _follewView.backgroundColor = [UIColor whiteColor];
        _follewView.layer.cornerRadius = 10;
        _follewView.layer.masksToBounds = YES;
    }
    return _follewView;
}

-(UILabel *)alertLabel{
    if (!_alertLabel) {
        _alertLabel = [UILabel new];
        _alertLabel.text = @"请实名认证";
        _alertLabel.textColor = [UIColor blackColor];
        _alertLabel.textAlignment = NSTextAlignmentCenter;
        _alertLabel.font = FONT20;
    }
    return _alertLabel;
}

-(UILabel *)msgLabel{
    if (!_msgLabel) {
        _msgLabel = [UILabel new];
        _msgLabel.text = @"您未进行实名认证，请进行实名\n认证后，进行后续操作!";
        _msgLabel.numberOfLines = 2;
        _msgLabel.textColor = [UIColor blackColor];
        _msgLabel.font = FONT14;
        _msgLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _msgLabel;
}

-(UIImageView *)canleImg{
    if (!_canleImg) {
        _canleImg = [UIImageView new];
//        _canleImg.image = [UIImage imageNamed:@"Frame"];
//        _canleImg.userInteractionEnabled = YES;
//        UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsTo_canleAlertView)];
//        [_canleImg addGestureRecognizer:ges];
    }
    return _canleImg;
}


-(UIButton *)enterRealNameBtn{
    if (!_enterRealNameBtn) {
        _enterRealNameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_enterRealNameBtn setTitle:@"去认证" forState:UIControlStateNormal];
        [_enterRealNameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _enterRealNameBtn.titleLabel.font = FONT15;
        _enterRealNameBtn.backgroundColor = COLOR_RGB(50, 113, 237);
        _enterRealNameBtn.layer.cornerRadius = 6;
        _enterRealNameBtn.layer.masksToBounds = YES;
        [_enterRealNameBtn addTarget:self action:@selector(respondsTo_enterRealNameBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _enterRealNameBtn;
}




@end
